/*-----------------------------------------------------------------------------------
 *
 * 프로그램명	: CommonDAO.java
 * Version		: 1.0
 * 작성일 		: 2006-08-16
 * 작성자		:
 * 수정일 		:
 * 수정자		:
 * 설명		 	:
 * 기능		 	:
 *
 * Copyright (c) 2000 by H&H  All Rights Reserved.
 *
-------------------------------------------------------------------------------------*/
package com.qbooks.common;

import java.io.*;
import java.util.*;
import java.sql.*;
import com.zll.framework.db.DBManager;
import com.zll.framework.model.HashList;


public class CommonDAO
{
	public HashList selectUser(HashMap infos) throws Exception
	{
        return DBManager.executeQuery("/common.xml", "select_user", infos);
	}

	public HashList selectManager(HashMap infos) throws Exception
	{
        return DBManager.executeQuery("/common.xml", "select_manager", infos);
	}

	public HashList selectUserList(HashMap infos) throws Exception
	{
        return DBManager.executeQuery("/common.xml", "select_user_list", infos);
	}

	public HashList selectCodeList(HashMap infos) throws Exception
	{
        return DBManager.executeQuery("/common.xml", "select_code_list", infos);
	}

	public HashList selectManagerList(HashMap infos) throws Exception
	{
        return DBManager.executeQuery("/common.xml", "select_manager_list", infos);
	}

	public HashList selectSeniorList(HashMap infos) throws Exception
	{
        return DBManager.executeQuery("/common.xml", "select_senior_list", infos);
	}
	
	public void updateLastLogin(HashMap infos) throws Exception
	{
		DBManager.executeUpdate("/common.xml", "update_user_last_login", infos);
	}

    /**
	 * Code 저장
	 *
	 * @param	infos
	 * @return	boolean
	 */
	public boolean saveCode(HashMap infos)
    {
		Connection conn = null;
        boolean result	= true;

        try
		{
			conn = DBManager.getConnection();

			if ("C".equals(infos.get("job_type"))) {
				DBManager.executeUpdate("/common.xml", "insert_code", infos, conn);
			}
			else if ("U".equals(infos.get("job_type"))) {
				DBManager.executeUpdate("/common.xml", "update_code", infos, conn);
			}
			else if ("D".equals(infos.get("job_type"))) {
				DBManager.executeUpdate("/common.xml", "delete_code", infos, conn);
			}


			/*
			ArrayList dataList = (ArrayList)infos.get("dataList");

		    for (int i = 0; i < dataList.size(); i++)
		    {
				HashMap map = (HashMap)dataList.get(i);

		    	if ("C".equals(map.get("job_type")))
		    	{
		    		DBManager.executeUpdate("/common.xml", "insert_code", map, conn);
		       	}
		       	else if ("U".equals(map.get("job_type")))
		       	{
		       		DBManager.executeUpdate("/common.xml", "update_code", map, conn);
		       	}
		       	else if ("D".equals(map.get("job_type")))
		       	{
		       		DBManager.executeUpdate("/common.xml", "delete_code", map, conn);
		        }
			}
			*/

			conn.commit();
	    }
	    catch(Exception e)
	    {
	    	e.printStackTrace();
	    	DBManager.rollback(conn);
	    	result 	= false;
		}
	    finally
	    {
	    	DBManager.closeConnection(conn);
		}

        return result;
    }


}
